/**
 * Copyright 2015 Software innovation and R & D center. All rights reserved.
 * File Name: ValidatorInterceptor.java
 * Encoding UTF-8
 * Version: 0.0.1
 * History:	2016年7月24日
 */
package net.huashitong.ssydt.provider.security.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 校验拦截器抽象类，用于参数校验
 * @author huiyang.yu
 * @version Revision: 0.0.1
 * @Date 2016年7月24日
 */
public abstract class ValidatorInterceptor implements HandlerInterceptor {
	
	
	  	@Override
	    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
	        return validate(request,response,handler);
	    }

	    /**
	     * 实现校验逻辑
	     * @param request
	     * @param response
	     * @return
	     * @throws IOException
	     */
	    protected abstract boolean validate(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException;

	    @Override
	    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
		}


	    @Override
	    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
	    }

}
